package com.accesshollywood.indexables;

import org.joda.time.DateTime;

import com.accesshollywood.SQL.GrfxDateTime;
import com.accesshollywood.grfxOrdering.basics.Users;

public class PreApprovedText extends Indexed {
	protected User			owner		= Users.unAssigned;
	protected GrfxDateTime	date		= new GrfxDateTime();
	protected String		reference	= "";
	protected String		entry		= "";
	protected String		notes		= "";

	@Override
	public void initSQL() {
		setThat(this);
		tableName = "preApproval";
		idColumnName = "idpreApproval";
		elementColumnName.put(getField("owner"), "idPerson");
		elementColumnName.put(getField("date"), "date");
		elementColumnName.put(getField("reference"), "reference");
		elementColumnName.put(getField("entry"), "entry");
		elementColumnName.put(getField("notes"), "notes");
	}

	public String toString() {
		return entry;
	}

	public synchronized User getOwner() {
		return owner;
	}

	public synchronized void setOwner(User owner) {
		this.owner = owner;
	}

	public synchronized GrfxDateTime getDate() {
		return date;
	}

	public synchronized void setDate(GrfxDateTime date) {
		this.date = date;
	}

	public synchronized String getReference() {
		return reference;
	}

	public synchronized void setReference(String reference) {
		this.reference = reference;
	}

	public synchronized String getEntry() {
		return entry;
	}

	public synchronized void setEntry(String entry) {
		this.entry = entry;
	}

	public synchronized String getNotes() {
		return notes;
	}

	public synchronized void setNotes(String notes) {
		this.notes = notes;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((date == null) ? 0 : date.hashCode());
		result = prime * result + ((entry == null) ? 0 : entry.hashCode());
		result = prime * result + ((notes == null) ? 0 : notes.hashCode());
		result = prime * result + ((owner == null) ? 0 : owner.hashCode());
		result = prime * result + ((reference == null) ? 0 : reference.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		PreApprovedText other = (PreApprovedText) obj;
		if (date == null) {
			if (other.date != null)
				return false;
		} else if (!date.equals(other.date))
			return false;
		if (entry == null) {
			if (other.entry != null)
				return false;
		} else if (!entry.equals(other.entry))
			return false;
		if (notes == null) {
			if (other.notes != null)
				return false;
		} else if (!notes.equals(other.notes))
			return false;
		if (owner == null) {
			if (other.owner != null)
				return false;
		} else if (!owner.equals(other.owner))
			return false;
		if (reference == null) {
			if (other.reference != null)
				return false;
		} else if (!reference.equals(other.reference))
			return false;
		return true;
	}
}
